ValueFolderTemp='C:\Users\Remy Neveu\Desktop\Etude IRM\Analyse\cc in2p3\Nature\ResultsJournal\';
ValueFolderTemp2='C:\Users\Remy Neveu\Desktop\Etude IRM\Analyse\cc in2p3\Nature\ResultsEditor\';
load([ValueFolderTemp 'ResultsThirdLevelDistributionOutliers.mat']);
VecDistribution=VecResults;
load('C:\Users\Remy Neveu\Desktop\Etude IRM\Analyse\cc in2p3\Nature\EtudeNature.mat');
VecEditors1Temp(1,:)=[];
VecValueEditor=VecEditors1Temp;
load('C:\Users\Remy Neveu\Desktop\Etude IRM\Analyse\cc in2p3\Nature\DonneesNature.mat');
VecValueJournal=VecJournalTemp;
load('C:\Users\Remy Neveu\Desktop\Etude IRM\Analyse\cc in2p3\Nature\Results\NCoAuthorsEditors.mat');
VecResultsCoAuthorsTemp=VecResultsCoAuthors;
VecValueJournalStart=xlsread('C:\Users\Remy Neveu\Desktop\Etude IRM\Analyse\pubmed\DonneesNature.xlsx',1);
ValueCutoff=1.25;
VecFigure=[];
VecFigure2=[];
VecFigure3=[];
VecFigure5=[];
VecFigure6=[];
VecResultsCoAuthors=[];
VecResultsCoAuthors2=[];
VecResultsCoAuthors3=[];
VecResultsEditorsCoAuthorsTemp=zeros(1,4);
VecResultsEditorsCoAuthorsTemp2=zeros(1,4);
VecResultsEditorsCoAuthorsTemp3=[];
VecResultsEditorAfter=[];
VecResultsEditorBefore=[];
VecResultsEditorTemp2=[];
VecResultsEditorCoAuthors=[];
VecResultsEditorCoAuthors2=[];
VecResultsEditorJournal=[];
VecResultsEditorJournal2=[];
VecResultsTemp5Temp=[];
VecResultsTemp6Temp=[];
VecResultsEditorsJournalBefore=[14 4;43 33;64 12;103 28;132 21;149 28;199 4;282 33;241 2];
for n1=1:323
    n1
    ValueTemp=find(VecDistribution(:,1)==n1);
    ValueStartEditor=VecValueEditor{n1,22};
    n5Temp5=0;
    if size(ValueTemp,1)==1&&n1~=11
        if VecDistribution(ValueTemp,2)<=ValueCutoff
            ValueJournal=VecValueEditor{n1,11};
            ValueTempBefore=find(VecResultsEditorsJournalBefore(:,1)==n1);
            if size(ValueTempBefore,1)==1
                n3=VecResultsEditorsJournalBefore(ValueTempBefore,2);
            else
                n3=1;
                TestTemp=0;
                while n3<=size(VecValueJournal,1)&&TestTemp==0
                    if strcmpi(ValueJournal,VecValueJournal{n3,1})==1
                        TestTemp=1;
                    else
                        n3=n3+1;
                    end
                end
            end
%             ValueFileTemp4=dir([ValueFolderTemp2 'FileAnalysisEditorCoAuthors' num2str(n1) 'RestrictedYear2Month8.mat']);
%             if size(ValueFileTemp4,1)==1
                load([ValueFolderTemp2 'FileAnalysisEditorCoAuthors' num2str(n1) 'RestrictedYear2Month8.mat']);
                if size(VecGroupCoAuthors,1)>=1
                    nCoAuthors=0;
                    nCoAuthors1=VecGroupCoAuthors{1,1};
                    nCoAuthors2=size(VecGroupCoAuthors,1);
                    for n7=1:size(VecGroupCoAuthors,1)
                        nCoAuthors=nCoAuthors+VecGroupCoAuthors{n7,1};
                    end
                else
                    nCoAuthors=NaN;
                    nCoAuthors1=NaN;
                    nCoAuthors2=NaN;
                end
                load([ValueFolderTemp2 'FileAnalysisCharacteristicsEditor' num2str(n1) '.mat']);
                VecValueTemp24=[];
                VecValueTemp25=[];
                VecValueTemp26=[];
                VecValueTemp24Temp=[];
                VecValueTemp25Temp=[];
                ValueTime=clock();
                n5Temp=0;
                for n2=1:33
                    if n2==n3
                        eval(['VecValueTemp=VecResultsCoAuthors' num2str(n2) 'j1y1m2;']);
%                         eval(['VecValueTemp=VecResultsCoAuthors' num2str(n2) 'j1y1m2Filtered;']); % robustness analysis for the first group of co-authors
                        VecValueTemp22=VecValueTemp';
                        eval(['VecValueTemp=VecResultsOtherAuthors' num2str(n2) 'j1y1m2;']);
%                         eval(['VecValueTemp=VecResultsOtherAuthors' num2str(n2) 'j1y1m2Filtered;']); % robustness analysis for the first group of co-authors
                        VecValueTemp23=VecValueTemp';
                        eval(['VecValueTemp2=VecResultsNameCoAuthors' num2str(n2) 'j1y1mFiltered;']); % robustness analysis for the first group of co-authors
                        VecResultsTemp5Temp=[VecResultsTemp5Temp;size(VecValueTemp22,1) size(VecValueTemp2,2) VecResultsCoAuthorsTemp(n1,1:3)];
                    else
                        eval(['VecValueTemp=VecResultsCoAuthors' num2str(n2) 'j1y1m2;']);
                        eval(['VecValueTemp3=VecResultsOtherAuthors' num2str(n2) 'j1y1m2;']);
%                         eval(['VecValueTemp=VecResultsCoAuthors' num2str(n2) 'j1y1m2Filtered;']); % robustness analysis for the first group of co-authors
%                         eval(['VecValueTemp3=VecResultsOtherAuthors' num2str(n2) 'j1y1m2Filtered;']); % robustness analysis for the first group of co-authors
                        if size(VecValueTemp24,2)==0&&size(VecValueTemp,2)>=1
                            VecValueTemp24=VecValueTemp;
                            VecValueTemp25=VecValueTemp;
                            VecValueTemp26=VecValueTemp3;
                            eval(['VecValueTemp2=VecResultsNameCoAuthors' num2str(n2) 'j1y1m;']);
%                             eval(['VecValueTemp2=VecResultsNameCoAuthors' num2str(n2) 'j1y1mFiltered;']); % robustness analysis for the first group of co-authors
                            VecValueTemp24Temp=VecValueTemp2;
                            n5Temp=n5Temp+1;
                        else
                            if size(VecValueTemp,2)>=1
                                eval(['VecValueTemp2=VecResultsNameCoAuthors' num2str(n2) 'j1y1m;']);
%                                 eval(['VecValueTemp2=VecResultsNameCoAuthors' num2str(n2) 'j1y1mFiltered;']); % robustness analysis for the first group of co-authors
                                for n4=1:size(VecValueTemp2,2)
                                    n5=1;
                                    TestTemp=0;
                                    while TestTemp==0&&n5<=size(VecValueTemp24Temp,2)
                                        if size(VecValueTemp24Temp{1,n5},2)==size(VecValueTemp2{1,n4},2)&&sum(abs(VecValueTemp24Temp{1,n5}-VecValueTemp2{1,n4}))==0
                                            TestTemp=1;
                                        else
                                            n5=n5+1;
                                        end
                                    end
                                    if n5<=size(VecValueTemp24Temp,2)
                                        VecValueTemp24(:,n5)=VecValueTemp24(:,n5)+VecValueTemp(:,n4);
                                    else
                                        VecValueTemp24(:,n5)=VecValueTemp(:,n4);
                                        VecValueTemp24Temp(1,n5)={VecValueTemp2{1,n4}};
                                    end
                                    n5Temp=n5Temp+1;
                                end
                                VecValueTemp25=[VecValueTemp25 VecValueTemp];
                                VecValueTemp26=[VecValueTemp26 VecValueTemp3];
                                if size(VecValueTemp2,2)>0
                                    n5Temp5=n5Temp5+1;
                                end
                            end
                        end
                    end
                end
                ValueTime2=clock();
                ValueTimeTemp=(ValueTime2(1,4)-ValueTime(1,4))*60+ValueTime2(1,5)-ValueTime(1,5);
                VecValueTemp24=VecValueTemp24';
                VecValueTemp24Temp=VecValueTemp24;
                if size(VecValueTemp22,1)>=1
                    ValueTemp5=find(isnan(VecValueTemp22(:,2))==0);
                    ValueTemp5=size(ValueTemp5,1);
                else
                    ValueTemp5=0;
                end
                if size(VecValueTemp24,1)>=1
                    ValueTemp4=find(isnan(VecValueTemp24(:,2))==0);
                    VecResultsCoAuthors=[VecResultsCoAuthors;size(ValueTemp4,1) ValueTemp5 VecResultsEditor(1,16) size(ValueTemp4,1)/VecResultsEditor(1,16) ValueTemp5/VecResultsEditor(1,16) VecResultsCoAuthorsTemp(n1,1:3) nCoAuthors1 nCoAuthors nCoAuthors2 n1];
                else
                    VecResultsCoAuthors=[VecResultsCoAuthors;0 ValueTemp5 VecResultsEditor(1,16) 0 ValueTemp5/VecResultsEditor(1,16) VecResultsCoAuthorsTemp(n1,1:3) nCoAuthors1 nCoAuthors nCoAuthors2 n1];
                end
                VecValueTemp24=VecValueTemp25';
                VecValueTemp26=VecValueTemp26';
                if size(VecValueTemp22,1)>=1&&size(VecValueTemp23,1)>=1
                    if size(VecValueEditor{n1,22},2)<=3||size(ValueTempBefore,1)==1
    %                 if size(VecValueTemp22,2)>=1&&size(VecValueTemp23,2)>=1&&size(VecValueEditor{n1,22},2)<=3&&VecResultsCoAuthors(end,1)<=15&&VecResultsCoAuthors(end,1)>=1
    %                 if size(VecValueTemp22,2)>=1&&size(VecValueTemp23,2)>=1&&size(VecValueEditor{n1,22},2)<=3&&VecResultsCoAuthors(end,5)<=13
                        % First column of VecValueTemp22 and VecValueTemp23 correspond to after the arrivla of the editor while the second column corresponds to before.
                        VecFigure3=[VecFigure3;VecValueTemp22 VecValueTemp22(:,1)+VecValueTemp22(:,2) VecValueTemp22(:,1)-VecValueTemp22(:,2) VecResultsEditor(1,1)*ones(size(VecValueTemp22,1),1) VecResultsEditor(1,16)*ones(size(VecValueTemp22,1),1) VecResultsEditor(1,27)*ones(size(VecValueTemp22,1),1) n3*ones(size(VecValueTemp22,1),1) ones(size(VecValueTemp22,1),1) size(VecValueTemp22,1)*ones(size(VecValueTemp22,1),1) n1*ones(size(VecValueTemp22,1),1)];
                        VecFigure3=[VecFigure3;VecValueTemp23 VecValueTemp23(:,1)+VecValueTemp23(:,2) VecValueTemp23(:,1)-VecValueTemp23(:,2) VecResultsEditor(1,1)*ones(size(VecValueTemp23,1),1) VecResultsEditor(1,16)*ones(size(VecValueTemp23,1),1) VecResultsEditor(1,27)*ones(size(VecValueTemp23,1),1) n3*ones(size(VecValueTemp23,1),1) 2*ones(size(VecValueTemp23,1),1) size(VecValueTemp22,1)*ones(size(VecValueTemp23,1),1) n1*ones(size(VecValueTemp23,1),1)];
                        if n1~=125&&n1~=151&&n1~=303
                            VecResultsEditorCoAuthors=[VecResultsEditorCoAuthors;VecResultsEditor(1,1) VecResultsEditor(1,16) VecResultsEditor(1,27) n1 size(VecValueTemp22,1) size(VecValueTemp23,1)];
                            ValueTemp=find(VecValueTemp22(:,1)==0&VecValueTemp22(:,2)>0);
                            ValueTemp2=find(VecValueTemp23(:,1)==0&VecValueTemp23(:,2)>0);
                            ValueTemp3=find(VecValueTemp22(:,2)>0|VecValueTemp22(:,1)>0);
                            ValueTemp4=find(VecValueTemp23(:,2)>0|VecValueTemp23(:,1)>0);
                            VecFigure5=[VecFigure5;size(ValueTemp,1) size(VecValueTemp22,1) size(ValueTemp2,1) size(VecValueTemp23,1) size(ValueTemp3,1) size(ValueTemp4,1) n3];
                        else
                            VecResultsEditorCoAuthors2=[VecResultsEditorCoAuthors2;VecResultsEditor(1,1) VecResultsEditor(1,16) VecResultsEditor(1,27) n1];
                        end
                        if n1~=125&&n1~=151&&n1~=303
                            if sum(VecValueTemp22(:,2))==0
                                if sum(VecValueTemp22(:,1))>0
                                    VecResultsEditorsCoAuthorsTemp(1,1)=VecResultsEditorsCoAuthorsTemp(1,1)+1;
                                else
                                    VecResultsEditorsCoAuthorsTemp(1,2)=VecResultsEditorsCoAuthorsTemp(1,2)+1;
                                end
                            else
                                if sum(VecValueTemp22(:,1))>0
                                    VecResultsEditorsCoAuthorsTemp(1,3)=VecResultsEditorsCoAuthorsTemp(1,3)+1;
                                else
                                    VecResultsEditorsCoAuthorsTemp(1,4)=VecResultsEditorsCoAuthorsTemp(1,4)+1;
                                end
                            end
                            ValueTemp=find(VecValueTemp22(:,2)==0&VecValueTemp22(:,1)>0); % Co-authors publish only after the editor's appointment
                            ValueTemp2=find(VecValueTemp22(:,1)==0&VecValueTemp22(:,2)>0); % Co-authors publish only before the editor's appointment
                            ValueTemp3=find(VecValueTemp22(:,1)>0|VecValueTemp22(:,2)>0);
                            VecResultsEditorsCoAuthorsTemp2(1,1)=VecResultsEditorsCoAuthorsTemp2(1,1)+size(ValueTemp,1);
                            VecResultsEditorsCoAuthorsTemp2(1,2)=VecResultsEditorsCoAuthorsTemp2(1,2)+size(ValueTemp2,1);
                            VecResultsEditorsCoAuthorsTemp2(1,3)=VecResultsEditorsCoAuthorsTemp2(1,3)+size(ValueTemp3,1);
                            if size(ValueTemp3,1)>0
                                VecResultsEditorsCoAuthorsTemp3=[VecResultsEditorsCoAuthorsTemp3;size(ValueTemp,1) size(ValueTemp2,1) nCoAuthors nCoAuthors1 size(ValueTemp3,1) n1];
                            end
                        end
                        if size(VecValueTemp24Temp,1)>=1
                            ValueTemp4=find(isnan(VecValueTemp24Temp(:,2))==0);
                            VecResultsCoAuthors3=[VecResultsCoAuthors3;size(ValueTemp4,1) ValueTemp5 VecResultsEditor(1,16) size(ValueTemp4,1)/VecResultsEditor(1,16) ValueTemp5/VecResultsEditor(1,16)];
                        else
                            VecResultsCoAuthors3=[VecResultsCoAuthors3;0 ValueTemp5 VecResultsEditor(1,16) 0 ValueTemp5/VecResultsEditor(1,16)];
                        end
                        if size(VecValueTemp25,1)>=1
                            VecValueTemp25=VecValueTemp25';
                            VecFigure6=[VecFigure6;VecValueTemp22 VecValueTemp22(:,1)+VecValueTemp22(:,2) VecValueTemp22(:,1)-VecValueTemp22(:,2) VecResultsEditor(1,1)*ones(size(VecValueTemp22,1),1) VecResultsEditor(1,16)*ones(size(VecValueTemp22,1),1) VecResultsEditor(1,27)*ones(size(VecValueTemp22,1),1) n3*ones(size(VecValueTemp22,1),1) ones(size(VecValueTemp22,1),1) size(VecValueTemp22,1)*ones(size(VecValueTemp22,1),1) n1*ones(size(VecValueTemp22,1),1) ones(size(VecValueTemp22,1),1)];
                            VecFigure6=[VecFigure6;VecValueTemp23 VecValueTemp23(:,1)+VecValueTemp23(:,2) VecValueTemp23(:,1)-VecValueTemp23(:,2) VecResultsEditor(1,1)*ones(size(VecValueTemp23,1),1) VecResultsEditor(1,16)*ones(size(VecValueTemp23,1),1) VecResultsEditor(1,27)*ones(size(VecValueTemp23,1),1) n3*ones(size(VecValueTemp23,1),1) 2*ones(size(VecValueTemp23,1),1) size(VecValueTemp22,1)*ones(size(VecValueTemp23,1),1) n1*ones(size(VecValueTemp23,1),1) ones(size(VecValueTemp23,1),1)];
                            VecFigure6=[VecFigure6;VecValueTemp25 VecValueTemp25(:,1)+VecValueTemp25(:,2) VecValueTemp25(:,1)-VecValueTemp25(:,2) VecResultsEditor(1,1)*ones(size(VecValueTemp25,1),1) VecResultsEditor(1,16)*ones(size(VecValueTemp25,1),1) VecResultsEditor(1,27)*ones(size(VecValueTemp25,1),1) n3*ones(size(VecValueTemp25,1),1) ones(size(VecValueTemp25,1),1) size(VecValueTemp25,1)*ones(size(VecValueTemp25,1),1) n1*ones(size(VecValueTemp25,1),1) 2*ones(size(VecValueTemp25,1),1)];
                            VecFigure6=[VecFigure6;VecValueTemp26 VecValueTemp26(:,1)+VecValueTemp26(:,2) VecValueTemp26(:,1)-VecValueTemp26(:,2) VecResultsEditor(1,1)*ones(size(VecValueTemp26,1),1) VecResultsEditor(1,16)*ones(size(VecValueTemp26,1),1) VecResultsEditor(1,27)*ones(size(VecValueTemp26,1),1) n3*ones(size(VecValueTemp26,1),1) 2*ones(size(VecValueTemp26,1),1) size(VecValueTemp25,1)*ones(size(VecValueTemp26,1),1) n1*ones(size(VecValueTemp26,1),1) 2*ones(size(VecValueTemp26,1),1)];
                        end
                    else
                        if size(VecValueTemp22,1)>=1&&size(VecValueTemp23,1)>=1
                            VecResultsTemp6Temp=[VecResultsTemp6Temp;n1];
                        end
                        VecResultsEditorCoAuthors2=[VecResultsEditorCoAuthors2;VecResultsEditor(1,1) VecResultsEditor(1,16) VecResultsEditor(1,27) n1];
                    end
                else
                    if size(VecValueTemp22,1)>=1&&size(VecValueTemp23,1)>=1
                        VecResultsTemp6Temp=[VecResultsTemp6Temp;n1];
                    end
                    VecResultsEditorCoAuthors2=[VecResultsEditorCoAuthors2;VecResultsEditor(1,1) VecResultsEditor(1,16) VecResultsEditor(1,27) n1];
                end
                if size(VecValueTemp24,2)>=1&&size(VecValueTemp22,2)>=1
                    if size(VecValueEditor{n1,22},2)<=3||size(ValueTempBefore,1)==1
    %                 if size(VecValueTemp24,2)>=1&&size(VecValueTemp22,2)>=1&&size(VecValueEditor{n1,22},2)<=3&&VecResultsCoAuthors(end,1)<=15&&VecResultsCoAuthors(end,1)>=1
    %                 if size(VecValueTemp24,2)>=1&&size(VecValueTemp22,2)>=1&&size(VecValueEditor{n1,22},2)<=3&&VecResultsCoAuthors(end,4)<=50
                        % First column of VecValueTemp24 and VecValueTemp23 correspond to after the arrivla of the editor while the second column corresponds to before.
                        VecFigure2=[VecFigure2;VecValueTemp22 VecValueTemp22(:,1)+VecValueTemp22(:,2) VecValueTemp22(:,1)-VecValueTemp22(:,2) VecResultsEditor(1,1)*ones(size(VecValueTemp22,1),1) VecResultsEditor(1,16)*ones(size(VecValueTemp22,1),1) VecResultsEditor(1,27)*ones(size(VecValueTemp22,1),1) n3*ones(size(VecValueTemp22,1),1) ones(size(VecValueTemp22,1),1) size(VecValueTemp22,1)*ones(size(VecValueTemp22,1),1) n1*ones(size(VecValueTemp22,1),1)];
    %                     VecFigure2=[VecFigure2;VecValueTemp24/n5Temp (VecValueTemp24(:,1)+VecValueTemp24(:,2)) (VecValueTemp24(:,1)-VecValueTemp24(:,2)) VecResultsEditor(1,1)*ones(size(VecValueTemp24,1),1) VecResultsEditor(1,16)*ones(size(VecValueTemp24,1),1) VecResultsEditor(1,27)*ones(size(VecValueTemp24,1),1) n3*ones(size(VecValueTemp24,1),1) 2*ones(size(VecValueTemp24,1),1) size(VecValueTemp24,1)*ones(size(VecValueTemp24,1),1) n1*ones(size(VecValueTemp24,1),1)];
                        VecFigure2=[VecFigure2;VecValueTemp24 VecValueTemp24(:,1)+VecValueTemp24(:,2) VecValueTemp24(:,1)-VecValueTemp24(:,2) VecResultsEditor(1,1)*ones(size(VecValueTemp24,1),1) VecResultsEditor(1,16)*ones(size(VecValueTemp24,1),1) VecResultsEditor(1,27)*ones(size(VecValueTemp24,1),1) n3*ones(size(VecValueTemp24,1),1) 2*ones(size(VecValueTemp24,1),1) size(VecValueTemp24,1)*ones(size(VecValueTemp24,1),1) n1*ones(size(VecValueTemp24,1),1)];
                        VecResultsEditorJournal=[VecResultsEditorJournal;VecResultsEditor(1,1) VecResultsEditor(1,16) VecResultsEditor(1,27)];
                        if size(VecValueTemp24Temp,1)>=1
                            ValueTemp4=find(isnan(VecValueTemp24Temp(:,2))==0);
                            VecResultsCoAuthors2=[VecResultsCoAuthors2;size(ValueTemp4,1) ValueTemp5 VecResultsEditor(1,16) size(ValueTemp4,1)/VecResultsEditor(1,16) ValueTemp5/VecResultsEditor(1,16)];
                        else
                            VecResultsCoAuthors2=[VecResultsCoAuthors2;0 ValueTemp5 VecResultsEditor(1,16) 0 ValueTemp5/VecResultsEditor(1,16)];
                        end
                    else
                        if size(VecValueEditor{n1,22},2)<=3
                            VecResultsEditorJournal2=[VecResultsEditorJournal2;VecResultsEditor(1,1) VecResultsEditor(1,16) VecResultsEditor(1,27)];
                        end
                    end
                else
                    if size(VecValueEditor{n1,22},2)<=3
                        VecResultsEditorJournal2=[VecResultsEditorJournal2;VecResultsEditor(1,1) VecResultsEditor(1,16) VecResultsEditor(1,27)];
                    end
                end
%                 % Robustness analysis (we average over the number of Nature journals)
%                 if size(VecValueTemp24,2)>=1&&size(VecValueTemp22,2)>=1&&size(VecValueEditor{n1,22},2)<=3&&n5Temp5>0
%                     % First column of VecValueTemp24 and VecValueTemp23 correspond to after the arrivla of the editor while the second column corresponds to before.
%                     VecFigure2=[VecFigure2;VecValueTemp22 VecValueTemp22(:,1)+VecValueTemp22(:,2) VecValueTemp22(:,1)-VecValueTemp22(:,2) VecResultsEditor(1,1)*ones(size(VecValueTemp22,1),1) VecResultsEditor(1,16)*ones(size(VecValueTemp22,1),1) VecResultsEditor(1,27)*ones(size(VecValueTemp22,1),1) n3*ones(size(VecValueTemp22,1),1) ones(size(VecValueTemp22,1),1) size(VecValueTemp22,1)*ones(size(VecValueTemp22,1),1) n1*ones(size(VecValueTemp22,1),1)];
% %                     VecFigure2=[VecFigure2;VecValueTemp24/n5Temp (VecValueTemp24(:,1)+VecValueTemp24(:,2))/n5Temp (VecValueTemp24(:,1)-VecValueTemp24(:,2))/n5Temp VecResultsEditor(1,1)*ones(size(VecValueTemp24,1),1) VecResultsEditor(1,16)*ones(size(VecValueTemp24,1),1) VecResultsEditor(1,27)*ones(size(VecValueTemp24,1),1) n3*ones(size(VecValueTemp24,1),1) 2*ones(size(VecValueTemp24,1),1) size(VecValueTemp24,1)*ones(size(VecValueTemp24,1),1) n1*ones(size(VecValueTemp24,1),1)];
%                     VecFigure2=[VecFigure2;VecValueTemp24/n5Temp5 VecValueTemp24(:,1)+VecValueTemp24(:,2) (VecValueTemp24(:,1)-VecValueTemp24(:,2))/n5Temp5 VecResultsEditor(1,1)*ones(size(VecValueTemp24,1),1) VecResultsEditor(1,16)*ones(size(VecValueTemp24,1),1) VecResultsEditor(1,27)*ones(size(VecValueTemp24,1),1) n3*ones(size(VecValueTemp24,1),1) 2*ones(size(VecValueTemp24,1),1) size(VecValueTemp24,1)*ones(size(VecValueTemp24,1),1) n1*ones(size(VecValueTemp24,1),1)];
%                 end
%             end
        end
    end
end

[ValueResults,ValueResults2,stats]=fishertest([VecResultsEditorsCoAuthorsTemp(1,1) VecResultsEditorsCoAuthorsTemp(1,4);sum(VecResultsEditorsCoAuthorsTemp(1,1:4))-VecResultsEditorsCoAuthorsTemp(1,1) sum(VecResultsEditorsCoAuthorsTemp(1,1:4))-VecResultsEditorsCoAuthorsTemp(1,4)]); % Comparison of the rate of editors whose co-authors publish exclusively before the editor's appointment to the rate of editors whose co-authors publish exclusively after the editor's appointment
% [ValueResults,ValueResults2,stats]=fishertest([VecResultsEditorsCoAuthorsTemp2(1,1) VecResultsEditorsCoAuthorsTemp2(1,2);VecResultsEditorsCoAuthorsTemp2(1,3)-VecResultsEditorsCoAuthorsTemp2(1,1) VecResultsEditorsCoAuthorsTemp2(1,3)-VecResultsEditorsCoAuthorsTemp2(1,2)]); % Comparison of the rate of editors whose co-authors publish exclusively before the editor's appointment to the rate of editors whose co-authors publish exclusively after the editor's appointment 
[ValueResult,ValueResult2]=ttest((VecResultsEditorsCoAuthorsTemp3(:,1)-VecResultsEditorsCoAuthorsTemp3(:,2))./VecResultsEditorsCoAuthorsTemp3(:,3));
[ValueResult3,ValueResult4]=signrank((VecResultsEditorsCoAuthorsTemp3(:,1)-VecResultsEditorsCoAuthorsTemp3(:,2))./VecResultsEditorsCoAuthorsTemp3(:,3));
VecResultsTemp=[mean(VecResultsEditorsCoAuthorsTemp3(:,1)./VecResultsEditorsCoAuthorsTemp3(:,3)*100) sqrt(var(VecResultsEditorsCoAuthorsTemp3(:,1)./VecResultsEditorsCoAuthorsTemp3(:,3)*100)) mean(VecResultsEditorsCoAuthorsTemp3(:,2)./VecResultsEditorsCoAuthorsTemp3(:,3)*100) sqrt(var(VecResultsEditorsCoAuthorsTemp3(:,2)./VecResultsEditorsCoAuthorsTemp3(:,3)*100)) mean(VecResultsEditorsCoAuthorsTemp3(:,5)./VecResultsEditorsCoAuthorsTemp3(:,3)*100) sqrt(var(VecResultsEditorsCoAuthorsTemp3(:,5)./VecResultsEditorsCoAuthorsTemp3(:,3)*100)) ValueResult2 ValueResult3];
VecResultsTemp=[VecResultsTemp;mean(VecResultsEditorsCoAuthorsTemp3(:,1)./VecResultsEditorsCoAuthorsTemp3(:,4)*100) sqrt(var(VecResultsEditorsCoAuthorsTemp3(:,1)./VecResultsEditorsCoAuthorsTemp3(:,4)*100)) mean(VecResultsEditorsCoAuthorsTemp3(:,2)./VecResultsEditorsCoAuthorsTemp3(:,4)*100) sqrt(var(VecResultsEditorsCoAuthorsTemp3(:,2)./VecResultsEditorsCoAuthorsTemp3(:,4)*100)) mean(VecResultsEditorsCoAuthorsTemp3(:,5)./VecResultsEditorsCoAuthorsTemp3(:,4)*100) sqrt(var(VecResultsEditorsCoAuthorsTemp3(:,5)./VecResultsEditorsCoAuthorsTemp3(:,4)*100)) ValueResult2 ValueResult3];


return

% VecResultsEditorTemp=[];
% VecResultsEditorAfter=VecResultsEditorCoAuthors;
% VecResultsEditorBefore=VecResultsEditorCoAuthors2;
% ValueTemp=find(VecResultsEditorAfter(:,1)==44);
% VecResultsEditorAfter(ValueTemp,:)=[];
% ValueTemp=find(VecResultsEditorBefore(:,1)==44);
% VecResultsEditorBefore(ValueTemp,:)=[];
% for n1=1:3
%     ValueTemp=find(isnan(VecResultsEditorAfter(:,n1))==0);
%     ValueTemp2=find(isnan(VecResultsEditorBefore(:,n1))==0);
%     [ValueResults,ValueResults2]=ttest2(VecResultsEditorAfter(ValueTemp,n1),VecResultsEditorBefore(ValueTemp2,n1));
%     [ValueResults3,ValueResults4]=ranksum(VecResultsEditorAfter(ValueTemp,n1),VecResultsEditorBefore(ValueTemp2,n1));
%     VecResultsEditorTemp=[VecResultsEditorTemp;mean(VecResultsEditorAfter(ValueTemp,n1)) sqrt(var(VecResultsEditorAfter(ValueTemp,n1))) median(VecResultsEditorAfter(ValueTemp,n1)) quantile(VecResultsEditorAfter(ValueTemp,n1),0.25) quantile(VecResultsEditorAfter(ValueTemp,n1),0.75) mean(VecResultsEditorBefore(ValueTemp2,n1)) sqrt(var(VecResultsEditorBefore(ValueTemp2,n1))) median(VecResultsEditorBefore(ValueTemp2,n1)) quantile(VecResultsEditorBefore(ValueTemp2,n1),0.25) quantile(VecResultsEditorBefore(ValueTemp2,n1),0.75) ValueResults2 ValueResults3 size(ValueTemp,1) size(ValueTemp2,1)];
% end
% VecResultsEditorAfter=VecResultsEditorJournal;
% VecResultsEditorBefore=VecResultsEditorJournal2;
% for n1=1:3
%     ValueTemp=find(isnan(VecResultsEditorAfter(:,n1))==0);
%     ValueTemp2=find(isnan(VecResultsEditorBefore(:,n1))==0);
%     [ValueResults,ValueResults2]=ttest2(VecResultsEditorAfter(ValueTemp,n1),VecResultsEditorBefore(ValueTemp2,n1));
%     [ValueResults3,ValueResults4]=ranksum(VecResultsEditorAfter(ValueTemp,n1),VecResultsEditorBefore(ValueTemp2,n1));
%     VecResultsEditorTemp=[VecResultsEditorTemp;mean(VecResultsEditorAfter(ValueTemp,n1)) sqrt(var(VecResultsEditorAfter(ValueTemp,n1))) median(VecResultsEditorAfter(ValueTemp,n1)) quantile(VecResultsEditorAfter(ValueTemp,n1),0.25) quantile(VecResultsEditorAfter(ValueTemp,n1),0.75) mean(VecResultsEditorBefore(ValueTemp2,n1)) sqrt(var(VecResultsEditorBefore(ValueTemp2,n1))) median(VecResultsEditorBefore(ValueTemp2,n1)) quantile(VecResultsEditorBefore(ValueTemp2,n1),0.25) quantile(VecResultsEditorBefore(ValueTemp2,n1),0.75) ValueResults2 ValueResults3 size(ValueTemp,1) size(ValueTemp2,1)];
% end

% ValueTemp=find(isnan(VecResultsCoAuthors(:,10))==0);
% VecResultsCoAuthorsTemp6=VecResultsCoAuthors(ValueTemp,:);
% ValueTemp=find(VecResultsCoAuthorsTemp6(:,10)-mean(VecResultsCoAuthorsTemp6(:,10))<=2*sqrt(var(VecResultsCoAuthorsTemp6(:,10))));
% ValueTemp=find(isnan(VecResultsCoAuthors(:,9))==0);
% VecResultsCoAuthorsTemp6=VecResultsCoAuthors(ValueTemp,:);
% ValueTemp=find(VecResultsCoAuthorsTemp6(:,9)-mean(VecResultsCoAuthorsTemp6(:,9))<=2*sqrt(var(VecResultsCoAuthorsTemp6(:,9))));

VecResultsFigure=[];
n2=5;
% for n2=3:7
    VecFigure=VecFigure3;
    ValueTemp=find(VecFigure(:,3)==0);
    VecFigure(ValueTemp,:)=[];
    ValueTemp=find(VecFigure(:,11)==125); % This editor has too many co-authors when using the threshold average+3*SD without the algorithm to remove homonyms (the algorithm does not converge to a non empty array)
    VecFigure(ValueTemp,:)=[];
    ValueTemp=find(VecFigure(:,11)==151); % This editor has too many co-authors when using the threshold average+3*SD without the algorithm to remove homonyms (the algorithm does not converge to a non empty array)
    VecFigure(ValueTemp,:)=[];
    ValueTemp=find(VecFigure(:,11)==303); % This editor has too many co-authors when using the threshold average+3*SD without the algorithm to remove homonyms (the algorithm does not converge to a non empty array)
    VecFigure(ValueTemp,:)=[];
    ValueTemp=find(abs(VecFigure(:,3)-mean(VecFigure(:,3)))<=n2*sqrt(var(VecFigure(:,3))));
    VecFigure=VecFigure(ValueTemp,:);
    for n1=1:3
        ValueTemp=find(isnan(VecFigure(n1+4,:))==1);
        if size(ValueTemp,1)>0
            VecFigure(ValueTemp,:)=[];
            VecValueTemp(ValueTemp,:)=[];
        end
    end
    VecValueTemp=repmat('O',size(VecFigure,1),1);
    ValueTemp=find(VecFigure(:,9)==1);
    VecValueTemp(ValueTemp,1)=repmat('E',size(ValueTemp,1),1);
    TestTemp=0;
    ValueTemp=1;
    while ValueTemp<=max(VecFigure(:,11))&&TestTemp==0
        ValueTemp2=find(VecFigure(:,11)==ValueTemp);
        if size(ValueTemp2,1)>=1
            VecValueTemp2=VecFigure(ValueTemp2,:);
            if VecValueTemp2(1,9)==1
                TestTemp=1;
            end
        end
        ValueTemp=ValueTemp+1;
    end
    VecFigure(ValueTemp2,:)=[];
    VecFigure=[VecValueTemp2;VecFigure];
    VecValueTemp=repmat('O',size(VecFigure,1),1);
    ValueTemp=find(VecFigure(:,9)==1);
    VecValueTemp(ValueTemp,1)=repmat('E',size(ValueTemp,1),1);
    VecValueTemp4=table(VecFigure(:,4),VecFigure(:,5),VecFigure(:,6),VecFigure(:,7),VecValueTemp,VecFigure(:,11),VecFigure(:,10),'VariableNames',{'Articles','Variable1','Variable16','Variable27','CategoryAuthor','Editor','CoAuthors'});
    ValueResultsModel1=fitlme(VecValueTemp4,'Articles~CategoryAuthor+(1|Editor)','FitMethod','REML');
    ValueTemp=find(VecValueTemp(:,1)=='O');
    VecFigure=[VecFigure(ValueTemp(1,1):end,:);VecFigure(1:ValueTemp(1,1)-1,:)];
    VecValueTemp=[VecValueTemp(ValueTemp(1,1):end,:);VecValueTemp(1:ValueTemp(1,1)-1,:)];
    % VecValueTemp5=[VecValueTemp5(ValueTemp(1,1):end,:);VecValueTemp5(1:ValueTemp(1,1)-1,:)];
    % VecValueTemp4=table([VecFigure(:,1);VecFigure(:,2)],[VecValueTemp;VecValueTemp],[repmat('A',size(VecFigure,1),1);repmat('B',size(VecFigure,1),1)],[VecFigure(:,11);VecFigure(:,11)],'VariableNames',{'Articles','CategoryAuthor','CategoryArticle','Editor'});
    % ValueResultsModel1Temp=fitlme(VecValueTemp4,'Articles~CategoryAuthor*CategoryArticle+(1|Editor)','FitMethod','REML');
    % VecValueTemp4=table([VecFigure(:,2);VecFigure(:,1)],[VecFigure(:,5);VecFigure(:,5)],[VecFigure(:,6);VecFigure(:,6)],[VecFigure(:,7);VecFigure(:,7)],[VecValueTemp;VecValueTemp],[repmat('B',size(VecFigure,1),1);repmat('A',size(VecFigure,1),1)],[VecFigure(:,11);VecFigure(:,11)],'VariableNames',{'Articles','Variable1','Variable16','Variable27','CategoryAuthor','CategoryArticle','Editor'});
    % ValueResultsModel1Temp2=fitlme(VecValueTemp4,'Articles~CategoryAuthor*CategoryArticle*Variable27+(1|Editor)','FitMethod','REML');
    % VecValueTemp4=table([VecFigure(:,2);VecFigure(:,1)],[VecFigure(:,5);VecFigure(:,5)],[VecFigure(:,6);VecFigure(:,6)],[VecFigure(:,7);VecFigure(:,7)],[VecValueTemp;VecValueTemp],[repmat('B',size(VecFigure,1),1);repmat('A',size(VecFigure,1),1)],[VecFigure(:,11);VecFigure(:,11)],'VariableNames',{'Articles','Variable1','Variable16','Variable27','CategoryAuthor','CategoryArticle','Editor'});
    % ValueResultsModel1Temp2=fitlme(VecValueTemp4,'Articles~CategoryAuthor*CategoryArticle+(1|Editor)','FitMethod','REML');
    VecValueTemp4=table(VecFigure(:,1)-VecFigure(:,2),VecFigure(:,5),VecFigure(:,6),VecFigure(:,7),VecValueTemp,VecFigure(:,2),VecFigure(:,11),'VariableNames',{'Articles','Variable1','Variable16','Variable27','CategoryAuthor','ArticlesBefore','Editor'});
    ValueResultsModel1Temp2=fitlme(VecValueTemp4,'Articles~CategoryAuthor+ArticlesBefore+(1|Editor)','FitMethod','REML'); % Mod�le pour l'article pour VecFigure3
    ValueResults=ValueResultsModel1Temp2.Coefficients(2,2).Estimate;
    ValueResults2=ValueResultsModel1Temp2.Coefficients(2,3).SE;
    ValueResults3=ValueResultsModel1Temp2.Coefficients(2,6).pValue;
    VecResultsFigure=[VecResultsFigure;-ValueResults ValueResults2 NaN ValueResults3 n2];
%     if n2==5
%         ValueResultsModel1Temp2
%     end
    VecValueTemp4=table(VecFigure(:,1)-VecFigure(:,2),VecFigure(:,5),VecFigure(:,6),VecFigure(:,7),VecValueTemp,VecFigure(:,2),VecFigure(:,11),'VariableNames',{'Articles','Variable1','Variable16','Variable27','CategoryAuthor','ArticlesBefore','Editor'});
%     ValueResultsModel1Temp2=fitlme(VecValueTemp4,'Articles~CategoryAuthor*Variable27+CategoryAuthor*Variable1+(1|Editor)','FitMethod','REML'); % Mod�le pour l'article pour VecFigure3
    ValueResultsModel1Temp2=fitlme(VecValueTemp4,'Articles~CategoryAuthor*Variable16+(1|Editor)','FitMethod','REML'); % Mod�le pour l'article pour VecFigure3 pour v�rifier que le recrutement des �diteurs na pas chang� au cours du temps
%     ValueResults=ValueResultsModel1Temp2.Coefficients(6,2).Estimate;
%     ValueResults2=ValueResultsModel1Temp2.Coefficients(6,3).SE;
%     ValueResults3=ValueResultsModel1Temp2.Coefficients(6,6).pValue;
%     VecResultsFigure=[VecResultsFigure;-ValueResults ValueResults2 NaN ValueResults3 n2];
    ValueResults=ValueResultsModel1Temp2.Coefficients(2,2).Estimate;
    ValueResults2=ValueResultsModel1Temp2.Coefficients(2,3).SE;
    ValueResults3=ValueResultsModel1Temp2.Coefficients(2,6).pValue;
    VecResultsFigure=[VecResultsFigure;ValueResults ValueResults2 NaN ValueResults3 n2];
    if n2==5
        ValueResultsModel1Temp2
    end
    VecValueTemp4=table(VecFigure(:,2),VecFigure(:,5),VecFigure(:,6),VecFigure(:,7),VecValueTemp,VecFigure(:,2),VecFigure(:,11),'VariableNames',{'Articles','Variable1','Variable16','Variable27','CategoryAuthor','ArticlesBefore','Editor'});
    ValueResultsModel1Temp4=fitlme(VecValueTemp4,'Articles~CategoryAuthor+(1|Editor)','FitMethod','REML'); % Mod�le pour l'article pour VecFigure3 pour comparer entre les co-auteurs et les autres auteurs le nombre d'articles publi�s avant l'arriv�e de l'�diteur
%     ValueResultsModel1Temp2=fitlme(VecValueTemp4,'Articles~CategoryAuthor*Variable16+(1|Editor)','FitMethod','REML'); % Mod�le pour l'article pour VecFigure3 pour v�rifier que le recrutement des �diteurs na pas chang� au cours du temps
%     ValueResults=ValueResultsModel1Temp4.Coefficients(2,2).Estimate;
%     ValueResults2=ValueResultsModel1Temp4.Coefficients(2,3).SE;
%     ValueResults3=ValueResultsModel1Temp4.Coefficients(2,6).pValue;
%     VecResultsFigure=[VecResultsFigure;-ValueResults ValueResults2 NaN ValueResults3 n2];
    ValueResults=ValueResultsModel1Temp2.Coefficients(2,2).Estimate;
    ValueResults2=ValueResultsModel1Temp2.Coefficients(2,3).SE;
    ValueResults3=ValueResultsModel1Temp2.Coefficients(2,6).pValue;
    VecResultsFigure=[VecResultsFigure;ValueResults ValueResults2 NaN ValueResults3 n2];
    if n2==5
        ValueResultsModel1Temp4
    end
    % VecValueTemp4=table(VecFigure(:,1)-VecFigure(:,2),VecFigure(:,5),VecFigure(:,6),VecFigure(:,7),VecValueTemp,VecFigure(:,2),VecFigure(:,11),'VariableNames',{'Articles','Variable1','Variable16','Variable27','CategoryAuthor','ArticlesBefore','Editor'});
    % ValueResultsModel1Temp2=fitlme(VecValueTemp4,'Articles~CategoryAuthor*Variable27+(1|Editor)','FitMethod','REML'); % Mod�le pour l'article pour VecFigure2
    % VecValueTemp4=table(VecFigure(:,1)-VecFigure(:,2),VecFigure(:,5),VecFigure(:,6),VecFigure(:,7),VecValueTemp,VecFigure(:,2),VecFigure(:,11),VecValueTemp5,'VariableNames',{'Articles','Variable1','Variable16','Variable27','CategoryAuthor','ArticlesBefore','Editor','Journal'});
    % ValueResultsModel1Temp2=fitlme(VecValueTemp4,'Articles~CategoryAuthor*Journal+ArticlesBefore+(1|Editor)','FitMethod','REML'); % Mod�le pour l'article pour VecFigure6
    % VecValueTemp4=table(VecFigure(:,4),VecFigure(:,5),VecFigure(:,6),VecFigure(:,7),VecValueTemp,repmat('A',size(VecFigure,1),1),VecFigure(:,11),'VariableNames',{'Articles','Variable1','Variable16','Variable27','CategoryAuthor','CategoryArticle','Editor'});
    % ValueResultsModel1Temp=fitlme(VecValueTemp4,'Articles~CategoryAuthor*Variable27+(1|Editor)','FitMethod','REML');
    % VecValueTemp4=table(VecFigure(:,4),VecFigure(:,5),VecFigure(:,6),VecFigure(:,7),VecValueTemp,repmat('A',size(VecFigure,1),1),VecFigure(:,11),'VariableNames',{'Articles','Variable1','Variable16','Variable27','CategoryAuthor','CategoryArticle','Editor'});
    % ValueResultsModel1Temp=fitlme(VecValueTemp4,'Articles~CategoryAuthor*Variable1+(1|Editor)','FitMethod','REML');
    % ValueResultsModel1Temp=fitlme(VecValueTemp4,'Articles~CategoryAuthor*Variable27+CategoryAuthor*Variable1+(1|Editor)','FitMethod','REML');
    VecFigureTemp=VecFigure;
    ValueTemp=find(VecFigureTemp(:,1)>=1);
    VecFigureTemp(ValueTemp,1)=ones(size(ValueTemp,1),1);
    ValueTemp=find(VecFigureTemp(:,2)>=1);
    VecFigureTemp=VecFigureTemp(ValueTemp,:);
    VecValueTemp=VecValueTemp(ValueTemp,:);
    % VecValueTemp5=[VecValueTemp5(4:end,:);VecValueTemp5(1:3,:)]; % If commented, results are for authors who arrived before
    % VecValueTemp=[VecValueTemp(4:end,:);VecValueTemp(1:3,:)]; % If commented, results are for authors who arrived before
    % VecFigureTemp=[VecFigureTemp(4:end,:);VecFigureTemp(1:3,:)]; % If commented, results are for authors who arrived before
    VecValueTemp4=table(VecFigureTemp(:,1),VecValueTemp,VecFigureTemp(:,2),VecFigureTemp(:,11),'VariableNames',{'ArticlesAfter','CategoryAuthor','ArticlesBefore','Editor'});
%     ValueResultsModel1Temp3=fitglme(VecValueTemp4,'ArticlesAfter~CategoryAuthor+ArticlesBefore+(1|Editor)','Distribution','Binomial','Link','logit','BinomialSize',1,'Weights',ones(size(VecFigureTemp,1),1),'FitMethod','laplace');
% %     ValueResultsModel1Temp3=fitglme(VecValueTemp4,'ArticlesAfter~CategoryAuthor*ArticlesBefore+(1|Editor)','Distribution','Binomial','Link','logit','BinomialSize',1,'Weights',ones(size(VecFigureTemp,1),1),'FitMethod','laplace');
%     ValueResults=ValueResultsModel1Temp3.Coefficients(2,2).Estimate;
%     ValueResults2=ValueResultsModel1Temp3.Coefficients(2,3).SE;
%     ValueResults3=ValueResultsModel1Temp3.Coefficients(2,6).pValue;
%     VecResultsFigure=[VecResultsFigure;exp(-ValueResults) exp(-ValueResults-1.96*ValueResults2) exp(-ValueResults+1.96*ValueResults2) ValueResults3 n2];
%     if n2==5
%         ValueResultsModel1Temp3
%     end
%     ValueResultsModel1Temp3
% end

% for n2=3:7
    VecFigure=VecFigure3;
    ValueTemp=find(VecFigure(:,3)==0);
    VecFigure(ValueTemp,:)=[];
    ValueTemp=find(VecFigure(:,11)==125); % This editor has too many co-authors when using the threshold average+3*SD without the algorithm to remove homonyms (the algorithm does not converge to a non empty array)
    VecFigure(ValueTemp,:)=[];
    ValueTemp=find(VecFigure(:,11)==151); % This editor has too many co-authors when using the threshold average+3*SD without the algorithm to remove homonyms (the algorithm does not converge to a non empty array)
    VecFigure(ValueTemp,:)=[];
    ValueTemp=find(VecFigure(:,11)==303); % This editor has too many co-authors when using the threshold average+3*SD without the algorithm to remove homonyms (the algorithm does not converge to a non empty array)
    VecFigure(ValueTemp,:)=[];
    [ValueTemp,ValueTemp2]=RemoveOutliers2(VecFigure,n2,3);
    VecFigure=ValueTemp;
    for n1=1:3
        ValueTemp=find(isnan(VecFigure(n1+4,:))==1);
        if size(ValueTemp,1)>0
            VecFigure(ValueTemp,:)=[];
            VecValueTemp(ValueTemp,:)=[];
        end
    end
    VecValueTemp=repmat('O',size(VecFigure,1),1);
    ValueTemp=find(VecFigure(:,9)==1);
    VecValueTemp(ValueTemp,1)=repmat('E',size(ValueTemp,1),1);
    TestTemp=0;
    ValueTemp=1;
    while ValueTemp<=max(VecFigure(:,11))&&TestTemp==0
        ValueTemp2=find(VecFigure(:,11)==ValueTemp);
        if size(ValueTemp2,1)>=1
            VecValueTemp2=VecFigure(ValueTemp2,:);
            if VecValueTemp2(1,9)==1
                TestTemp=1;
            end
        end
        ValueTemp=ValueTemp+1;
    end
    VecFigure(ValueTemp2,:)=[];
    VecFigure=[VecValueTemp2;VecFigure];
    VecValueTemp=repmat('O',size(VecFigure,1),1);
    ValueTemp=find(VecFigure(:,9)==1);
    VecValueTemp(ValueTemp,1)=repmat('E',size(ValueTemp,1),1);
    VecValueTemp4=table(VecFigure(:,4),VecFigure(:,5),VecFigure(:,6),VecFigure(:,7),VecValueTemp,VecFigure(:,11),VecFigure(:,10),'VariableNames',{'Articles','Variable1','Variable16','Variable27','CategoryAuthor','Editor','CoAuthors'});
    ValueResultsModel1=fitlme(VecValueTemp4,'Articles~CategoryAuthor+(1|Editor)','FitMethod','REML');
    ValueTemp=find(VecValueTemp(:,1)=='O');
    VecFigure=[VecFigure(ValueTemp(1,1):end,:);VecFigure(1:ValueTemp(1,1)-1,:)];
    VecValueTemp=[VecValueTemp(ValueTemp(1,1):end,:);VecValueTemp(1:ValueTemp(1,1)-1,:)];
    % VecValueTemp5=[VecValueTemp5(ValueTemp(1,1):end,:);VecValueTemp5(1:ValueTemp(1,1)-1,:)];
    % VecValueTemp4=table([VecFigure(:,1);VecFigure(:,2)],[VecValueTemp;VecValueTemp],[repmat('A',size(VecFigure,1),1);repmat('B',size(VecFigure,1),1)],[VecFigure(:,11);VecFigure(:,11)],'VariableNames',{'Articles','CategoryAuthor','CategoryArticle','Editor'});
    % ValueResultsModel1Temp=fitlme(VecValueTemp4,'Articles~CategoryAuthor*CategoryArticle+(1|Editor)','FitMethod','REML');
    % VecValueTemp4=table([VecFigure(:,2);VecFigure(:,1)],[VecFigure(:,5);VecFigure(:,5)],[VecFigure(:,6);VecFigure(:,6)],[VecFigure(:,7);VecFigure(:,7)],[VecValueTemp;VecValueTemp],[repmat('B',size(VecFigure,1),1);repmat('A',size(VecFigure,1),1)],[VecFigure(:,11);VecFigure(:,11)],'VariableNames',{'Articles','Variable1','Variable16','Variable27','CategoryAuthor','CategoryArticle','Editor'});
    % ValueResultsModel1Temp2=fitlme(VecValueTemp4,'Articles~CategoryAuthor*CategoryArticle*Variable27+(1|Editor)','FitMethod','REML');
    % VecValueTemp4=table([VecFigure(:,2);VecFigure(:,1)],[VecFigure(:,5);VecFigure(:,5)],[VecFigure(:,6);VecFigure(:,6)],[VecFigure(:,7);VecFigure(:,7)],[VecValueTemp;VecValueTemp],[repmat('B',size(VecFigure,1),1);repmat('A',size(VecFigure,1),1)],[VecFigure(:,11);VecFigure(:,11)],'VariableNames',{'Articles','Variable1','Variable16','Variable27','CategoryAuthor','CategoryArticle','Editor'});
    % ValueResultsModel1Temp2=fitlme(VecValueTemp4,'Articles~CategoryAuthor*CategoryArticle+(1|Editor)','FitMethod','REML');
    VecValueTemp4=table(VecFigure(:,1)-VecFigure(:,2),VecFigure(:,5),VecFigure(:,6),VecFigure(:,7),VecValueTemp,VecFigure(:,2),VecFigure(:,11),'VariableNames',{'Articles','Variable1','Variable16','Variable27','CategoryAuthor','ArticlesBefore','Editor'});
%     ValueResultsModel1Temp2=fitlme(VecValueTemp4,'Articles~CategoryAuthor+ArticlesBefore+(1|Editor)','FitMethod','REML'); % Mod�le pour l'article pour VecFigure3
%     ValueResults=ValueResultsModel1Temp2.Coefficients(2,2).Estimate;
%     ValueResults2=ValueResultsModel1Temp2.Coefficients(2,3).SE;
%     ValueResults3=ValueResultsModel1Temp2.Coefficients(2,6).pValue;
%     VecResultsFigure=[VecResultsFigure;-ValueResults ValueResults2 NaN ValueResults3 n2];
%     if n2==5
%         ValueResultsModel1Temp2
%     end
    VecValueTemp4=table(VecFigure(:,1)-VecFigure(:,2),VecFigure(:,5),VecFigure(:,6),VecFigure(:,7),VecValueTemp,VecFigure(:,2),VecFigure(:,11),'VariableNames',{'Articles','Variable1','Variable16','Variable27','CategoryAuthor','ArticlesBefore','Editor'});
%     ValueResultsModel1Temp2=fitlme(VecValueTemp4,'Articles~CategoryAuthor*Variable27+CategoryAuthor*Variable1+(1|Editor)','FitMethod','REML'); % Mod�le pour l'article pour VecFigure3
    ValueResultsModel1Temp2=fitlme(VecValueTemp4,'Articles~CategoryAuthor*Variable16+(1|Editor)','FitMethod','REML'); % Mod�le pour l'article pour VecFigure3 pour v�rifier que le recrutement des �diteurs na pas chang� au cours du temps
%     ValueResults=ValueResultsModel1Temp2.Coefficients(6,2).Estimate;
%     ValueResults2=ValueResultsModel1Temp2.Coefficients(6,3).SE;
%     ValueResults3=ValueResultsModel1Temp2.Coefficients(6,6).pValue;
%     VecResultsFigure=[VecResultsFigure;-ValueResults ValueResults2 NaN ValueResults3 n2];
    ValueResults=ValueResultsModel1Temp2.Coefficients(2,2).Estimate;
    ValueResults2=ValueResultsModel1Temp2.Coefficients(2,3).SE;
    ValueResults3=ValueResultsModel1Temp2.Coefficients(2,6).pValue;
    VecResultsFigure=[VecResultsFigure;ValueResults ValueResults2 NaN ValueResults3 n2];
    if n2==5
        ValueResultsModel1Temp2
    end
    VecValueTemp4=table(VecFigure(:,2),VecFigure(:,5),VecFigure(:,6),VecFigure(:,7),VecValueTemp,VecFigure(:,2),VecFigure(:,11),'VariableNames',{'Articles','Variable1','Variable16','Variable27','CategoryAuthor','ArticlesBefore','Editor'});
    ValueResultsModel1Temp4=fitlme(VecValueTemp4,'Articles~CategoryAuthor+(1|Editor)','FitMethod','REML'); % Mod�le pour l'article pour VecFigure3 pour comparer entre les co-auteurs et les autres auteurs le nombre d'articles publi�s avant l'arriv�e de l'�diteur
%     ValueResultsModel1Temp2=fitlme(VecValueTemp4,'Articles~CategoryAuthor*Variable16+(1|Editor)','FitMethod','REML'); % Mod�le pour l'article pour VecFigure3 pour v�rifier que le recrutement des �diteurs na pas chang� au cours du temps
%     ValueResults=ValueResultsModel1Temp4.Coefficients(2,2).Estimate;
%     ValueResults2=ValueResultsModel1Temp4.Coefficients(2,3).SE;
%     ValueResults3=ValueResultsModel1Temp4.Coefficients(2,6).pValue;
%     VecResultsFigure=[VecResultsFigure;-ValueResults ValueResults2 NaN ValueResults3 n2];
    ValueResults=ValueResultsModel1Temp2.Coefficients(2,2).Estimate;
    ValueResults2=ValueResultsModel1Temp2.Coefficients(2,3).SE;
    ValueResults3=ValueResultsModel1Temp2.Coefficients(2,6).pValue;
    VecResultsFigure=[VecResultsFigure;ValueResults ValueResults2 NaN ValueResults3 n2];
    if n2==5
        ValueResultsModel1Temp4
    end
    % VecValueTemp4=table(VecFigure(:,1)-VecFigure(:,2),VecFigure(:,5),VecFigure(:,6),VecFigure(:,7),VecValueTemp,VecFigure(:,2),VecFigure(:,11),'VariableNames',{'Articles','Variable1','Variable16','Variable27','CategoryAuthor','ArticlesBefore','Editor'});
    % ValueResultsModel1Temp2=fitlme(VecValueTemp4,'Articles~CategoryAuthor*Variable27+(1|Editor)','FitMethod','REML'); % Mod�le pour l'article pour VecFigure2
    % VecValueTemp4=table(VecFigure(:,1)-VecFigure(:,2),VecFigure(:,5),VecFigure(:,6),VecFigure(:,7),VecValueTemp,VecFigure(:,2),VecFigure(:,11),VecValueTemp5,'VariableNames',{'Articles','Variable1','Variable16','Variable27','CategoryAuthor','ArticlesBefore','Editor','Journal'});
    % ValueResultsModel1Temp2=fitlme(VecValueTemp4,'Articles~CategoryAuthor*Journal+ArticlesBefore+(1|Editor)','FitMethod','REML'); % Mod�le pour l'article pour VecFigure6
    % VecValueTemp4=table(VecFigure(:,4),VecFigure(:,5),VecFigure(:,6),VecFigure(:,7),VecValueTemp,repmat('A',size(VecFigure,1),1),VecFigure(:,11),'VariableNames',{'Articles','Variable1','Variable16','Variable27','CategoryAuthor','CategoryArticle','Editor'});
    % ValueResultsModel1Temp=fitlme(VecValueTemp4,'Articles~CategoryAuthor*Variable27+(1|Editor)','FitMethod','REML');
    % VecValueTemp4=table(VecFigure(:,4),VecFigure(:,5),VecFigure(:,6),VecFigure(:,7),VecValueTemp,repmat('A',size(VecFigure,1),1),VecFigure(:,11),'VariableNames',{'Articles','Variable1','Variable16','Variable27','CategoryAuthor','CategoryArticle','Editor'});
    % ValueResultsModel1Temp=fitlme(VecValueTemp4,'Articles~CategoryAuthor*Variable1+(1|Editor)','FitMethod','REML');
    % ValueResultsModel1Temp=fitlme(VecValueTemp4,'Articles~CategoryAuthor*Variable27+CategoryAuthor*Variable1+(1|Editor)','FitMethod','REML');
    VecFigureTemp=VecFigure;
    ValueTemp=find(VecFigureTemp(:,1)>=1);
    VecFigureTemp(ValueTemp,1)=ones(size(ValueTemp,1),1);
    ValueTemp=find(VecFigureTemp(:,2)>=1);
    VecFigureTemp=VecFigureTemp(ValueTemp,:);
    VecValueTemp=VecValueTemp(ValueTemp,:);
    % VecValueTemp5=[VecValueTemp5(4:end,:);VecValueTemp5(1:3,:)]; % If commented, results are for authors who arrived before
    % VecValueTemp=[VecValueTemp(4:end,:);VecValueTemp(1:3,:)]; % If commented, results are for authors who arrived before
    % VecFigureTemp=[VecFigureTemp(4:end,:);VecFigureTemp(1:3,:)]; % If commented, results are for authors who arrived before
    VecValueTemp4=table(VecFigureTemp(:,1),VecValueTemp,VecFigureTemp(:,2),VecFigureTemp(:,11),'VariableNames',{'ArticlesAfter','CategoryAuthor','ArticlesBefore','Editor'});
%     ValueResultsModel1Temp3=fitglme(VecValueTemp4,'ArticlesAfter~CategoryAuthor+ArticlesBefore+(1|Editor)','Distribution','Binomial','Link','logit','BinomialSize',1,'Weights',ones(size(VecFigureTemp,1),1),'FitMethod','laplace');
%     ValueResults=ValueResultsModel1Temp3.Coefficients(2,2).Estimate;
%     ValueResults2=ValueResultsModel1Temp3.Coefficients(2,3).SE;
%     ValueResults3=ValueResultsModel1Temp3.Coefficients(2,6).pValue;
%     VecResultsFigure=[VecResultsFigure;exp(-ValueResults) exp(-ValueResults-1.96*ValueResults2) exp(-ValueResults+1.96*ValueResults2) ValueResults3 n2];
%     if n2==5
%         ValueResultsModel1Temp3
%     end
% end
% save('C:\Users\Remy Neveu\Desktop\Etude IRM\Analyse\ResultsFigureAllCoAuthors.mat','VecResultsFigure');
% save('C:\Users\Remy Neveu\Desktop\Etude IRM\Analyse\ResultsFigureFirstGroupCoAuthorsBiasesOtherAuthors.mat','VecResultsFigure');
